#include "friend.h"
#ifndef FRIENDMODEL_H
#define FRIENDMODEL_H

#include <QAbstractListModel>

class FriendModel : public QAbstractListModel
{
    Q_OBJECT

public:
    explicit FriendModel(QObject *parent = nullptr);

    // Basic functionality:
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

    QHash<int, QByteArray> roleNames() const;

    Q_INVOKABLE void reset();
    Q_INVOKABLE void FilterByName(QString filter);
    Q_INVOKABLE void ClearFilter();

    enum FriendRoles {
        NameRole = Qt::UserRole + 1,
        StateRole,
        SIDRole
    };

private:
    QList<Friend> friends;
    QList<Friend> filtered_friends;
    QString filter;
};

#endif // FRIENDMODEL_H
